package cn.eclass.utils;

import java.text.DateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;

import cn.eclass.entity.SchoolEntity;
import cn.eclass.entity.SchoolOrderEntity;

public class SchoolOrderObject {
//    private float amount;
//    private float claimAmount;
//    private int schoolId;
//    private String thedate;
//    private String status;
////    private String status = ConstantsConf.SCHOOLORDER_INVALID;
//    private int points;
//    private String orderNo = null;
//    private String className = null;
//    
//    //school:
//    private String schoolLink;
//    private String schoolName;
//    private String schoolLogo;
    
    private SchoolOrderEntity soe = null;
    private SchoolEntity se = null;
    
    private String int2Str(int valid){
    	if(valid == 1) return ConstantsConf.String_Valid;
    	return ConstantsConf.String_InValid;
    }
    
    private int str2Int(String str) {
    	if(str.equals("valid")) return 1;
    	return 0;
    }
    
    public SchoolOrderObject(SchoolOrderEntity soe) {
    	this.soe = soe;
    	int schoolId = soe.getSchoolId();
    	se = BeanFactory.factory.getSchoolBean().get(schoolId);
    	
//    	amount = soe.getAmount();
//    	claimAmount = soe.getClaimAmount();
//    	schoolId = soe.getSchoolId();
//    	thedate = new Date(soe.getThedate()).toString();
//    	
//    	status = int2Str(soe.getValid());
//    	points = soe.getPoints();
//    	orderNo = soe.getOrderNo();
//    	className = soe.getClassName();
//    	
//    	SchoolEntity se = BeanFactory.factory.getSchoolBean().get(schoolId);
//    	schoolLink = se.getLink();
//    	schoolName = se.getName();
//    	schoolLogo = se.getLogo();
    }
    

    public String getStatus() {
		return int2Str(soe.getValid());
	}
    
    public boolean isValid() {
    	if(soe.getValid() == 1) return true;
    	return false;
    }
    
    public float getClaimAmount() {
		return soe.getClaimAmount();
	}

	public String getSchoolLink() {
		return se.getLink();
	}

	public String getSchoolName() {
		return se.getName();
	}

	public String getSchoolLogo() {
		return se.getLogo();
	}

	public String getClassName() {
		return soe.getClassName();
	}

	public float getAmount() {
		return soe.getAmount();
	}

	public int getSchoolId() {
		return soe.getSchoolId();
	}

	public String getThedate() {
		long time = soe.getThedate();
		
		Date d = new Date(time);
		DateFormat df = DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL, Locale.CHINESE);
		String fTime = df.format(d);
		return fTime;
	}
	
	public int getPoints() {
		return soe.getPoints();
	}

	public String getOrderNo() {
		return soe.getOrderNo();
	}
	
	public int getOrderId() {
		return soe.getId();
	}
    
}
